<?php

/**
 * RP System
 *
 * @version 1.0
 * @copyright 2004 Ron Planken
 */

class rp_category {


	function get($category_id = 0){

		global $dbh;

		if ($category_id == 0) {
			$query ='SELECT  category_id
							,category_short_name
							,category_long_name
							,category_image
						FROM raid_points_category
					ORDER BY category_id;
							';
		} else {
			$query = "SELECT  category_id
							,category_short_name
							,category_long_name
							,category_image
						FROM raid_points_category
					   WHERE category_id = $category_id;
							";
		}


		$categories = SelectMultiQuery($query, $dbh);

		return $categories;

	}

	function save($category_id, $category_short_name, $category_long_name, $category_image) {

		global $dbh;

		$rp_id = secure_int($rp_id);
        $category_id =  secure_int($category_id);
        $category_short_name = secure_string($category_short_name);
        $category_long_name = secure_string($category_long_name);
        $category_image = secure_string($category_image);

		if ($rp_id == 0) {
			$query ="INSERT INTO raid_points_category
						   (category_id
			               ,category_short_name
			               ,category_long_name
			               ,category_image)
					VALUES ($category_id
			               ,$category_short_name
			               ,$category_long_name
			               ,$category_image)
							";
			$status = InsertQuery($query, $dbh);

		} else {
			$query ="UPDATE raid_points_category
						SET category_short_name = $category_short_name
						   ,category_long_name = $category_long_named
						   ,category_image = $category_image
					  WHERE category_id = $category_id
							";
			$status = UpdateQuery($query, $dbh);
		}

		return $status;

	}


	function remove($category_id = 0) {

		global $dbh;

		$category_id = secure_int($category_id);

		$query ="DELETE FROM raid_points_category
				  	   WHERE category_id = $category_id;
							";
		$status = UpdateQuery($query, $dbh);



		return $status;
	}

}
?>